package cn.yr.clock.mapper;

import cn.yr.clock.domain.entity.Prize;
import cn.yr.clock.domain.vo.PrizeVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 
 * @author Lang
 * @email 1102076808@qq.com
 * @date 2021-09-25 11:13:41
 */
@Mapper
public interface PrizeMapper extends BaseMapper<Prize> {

    @Select("select a.*,b.sum,b.used from prize a left join (select prize_id,count(*) sum,count(user_id or null) used from prize_instance group  by  prize_id) b on a.prize_id = b.prize_id;")
    List<PrizeVo> selectPrizeInventory();
}
